package com.aliwo.design2.singleton;

/**
 * 单例模式 懒汉模式 线程不安全.
 *
 * @author Xu Yayuan
 * @date 2022/5/5
 */
public class SingletonDemo01 {

    // 一：私有构造方法 避免外部实例化
    private SingletonDemo01(){}
    // 二: 单例变量
    private static SingletonDemo01 instance;

    public static SingletonDemo01 getInstance() {
        if (null != instance ) {
            return instance;
        }
        instance = new SingletonDemo01();
        return instance;
    }
}
